/*
 * Created on 2005-9-23
 *
 * To change the template for this generated file go to
 * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
 */
package com.bytime.permission.deptmanage.action;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionError;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import com.bytime.permission.deptmanage.busi.BCteamDepInfoBean;
import com.bytime.permission.deptmanage.enti.CteamDepInfo;
import com.bytime.permission.exception.SystemException;
/**
 * @author Administrator
 *
 * To change the template for this generated type comment go to
 * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
 */
public class teamDeptManage002Action extends Action
{
	static String teamDeptManage001checks = "teamDeptManage001checks";
	static String strCompCode = "compCode";
	static String strCompName = "compName";
	static String strUpperComp = "upperComp";
	static String strTelNo = "telNo";
	static String strSuperPeople = "superPeople";
	static String strAction = "action";
	static String strDelete = "delete";
	static String strDoDelete = "dodelete";
	static String strReturn = "return";
	static String strRsClub001 = "rsClub001";
	static String strRsClubDel = "rsClubdel";
	static String strPageNo = "pageNo";
	static String strSysEr = "systemerror";
	public String action = "";
	public ActionForward execute(
		ActionMapping actionMapping,
		ActionForm actionForm,
		HttpServletRequest httpServletRequest,
		HttpServletResponse httpServletResponse)
		throws Exception
	{
		teamDeptManage002Form objForm = (teamDeptManage002Form) actionForm;
		try
		{
			BCteamDepInfoBean info = new BCteamDepInfoBean();
			HttpServletRequest request = httpServletRequest;
			if (request.getParameter(strAction) == null
				|| request.getParameter(strAction).equals(""))
			{
				action = strDelete;
			}
			else
			{
				action = request.getParameter(strAction);
			}
			if (action.equals(strDelete))
			{
				String[] strArrDel =
					request.getParameterValues(teamDeptManage001checks);
				List list = getCteamDepInfos(strArrDel);
				request.setAttribute(strRsClubDel, list);
				return (actionMapping.findForward(strDelete));
			}
			if (action.equals(strReturn))
			{
				//request.setAttribute(strRsClub001,info.getCteamDepInfos());
				return (actionMapping.findForward(strReturn));
			}
			if (action.equals(strDoDelete))
			{
				return (actionMapping.findForward(strDoDelete));
			}
		}
		catch (SystemException e)
		{
			ActionErrors errors = new ActionErrors();
			errors.add(strSysEr, new ActionError(e.getMessage()));
			saveErrors(httpServletRequest, errors);
			if(action.equals(strDoDelete))
			{
				objForm.setAction(strDelete);
				return (actionMapping.findForward(strDelete));
			}
			else
			{
				return(actionMapping.findForward(strReturn));
			} 
		}
		return null;
	}
	public List getCteamDepInfos(String[] strArrDel) throws Exception
	{
		BCteamDepInfoBean info = new BCteamDepInfoBean();
		ArrayList list = new ArrayList();
		CteamDepInfo objTeamDepInfo = new CteamDepInfo(), objTeamDepInfo_1;
		if (strArrDel == null)
		{
			return null;
		}
		for (int i = 0; i < strArrDel.length; i++)
		{
			objTeamDepInfo.setDept_code(strArrDel[i]);
			objTeamDepInfo_1 =(CteamDepInfo) info.getCteamDepInfo(objTeamDepInfo);
			objTeamDepInfo.setDept_code(objTeamDepInfo_1.getDept_code());
			objTeamDepInfo.setDept_name(objTeamDepInfo_1.getDept_name());
			objTeamDepInfo.setParent_dept_code(objTeamDepInfo_1.getParent_dept_code());
			objTeamDepInfo.setPhone(objTeamDepInfo_1.getPhone());
			objTeamDepInfo.setSuper_people(objTeamDepInfo_1.getSuper_people());
			list.add(objTeamDepInfo);
	
		}
		return list;
	}
}
